/**
 * 
 */
package mblog.core.pojos;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * @author langhsu
 * 
 */
public class Comment implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5138768351916838965L;
	// FIXME: use enum instead of constants
	public static int COMMENT_TO_PRODUCT = 0;
	public static int COMMENT_TO_POST = 1;
	public static int INBOXMSG_TO_USER = 2;
	public static int COMMENT_TO_CHANNEL = 3;
	public static int COMMENT_TO_LIVE_MSG = 4;

	private long id;
	private long toId;
	private Post toPost;
	private Tag toTag;
	private User toUser;
	private String content;
	private Date created;
	private User author;
	private int status;
	// 0对产品评论，1对文章评论, 2用户站内信
	private int type = 0;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getToId() {
		return toId;
	}

	public void setToId(long toId) {
		this.toId = toId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@DateTimeFormat(pattern = "yyyy-MM-dd")
	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Post getToPost() {
		return toPost;
	}

	public void setToPost(Post toPost) {
		this.toPost = toPost;
	}

	public Tag getToTag() {
		return toTag;
	}

	public void setToTag(Tag toTag) {
		this.toTag = toTag;
	}

	public User getToUser() {
		return toUser;
	}

	public void setToUser(User toUser) {
		this.toUser = toUser;
	}

	public static class Comparators {

		public static Comparator<Comment> ID_DESC = new Comparator<Comment>() {
			@Override
			public int compare(Comment o1, Comment o2) {
				int ret = (int) (o2.id - o1.id);// id desc
				return ret;
			}
		};
	}
}
